#include "FIDataCenter.h"
#include <qbprotocol/include/rdProto.h>
#include <qbprotocol/include/SSMsgStruct.h>

FIDataCenter::FIDataCenter()
{
}

FIDataCenter& FIDataCenter::instance()
{
	static FIDataCenter s_fiData;
	return s_fiData;
}

void FIDataCenter::reqCIBRepo()
{
	m_dataCIBRepo.reqData(this);
}

void FIDataCenter::reqShibor()
{
	m_dataShibor.reqData(this);
}

void FIDataCenter::reqExchRepo()
{
	m_dataExchRepo.reqData(this);
}

void FIDataCenter::reqIRS()
{
	m_dataIRS.reqData(this);
}

void FIDataCenter::reqRepoFixing()
{
	m_dataRepoFixing.reqData(this);
}

void FIDataCenter::reqCIBRepoFixing()
{
	m_dataCIBRepoFixing.reqData(this);
}

void FIDataCenter::reqGMktIndex(const std::vector<int> current_indexes)
{
    m_dataGMktIndex.reqData(this, current_indexes);
}

void FIDataCenter::reqPublicOption()
{
	m_dataOMO.reqData(this);
	m_dataOMO.reqSetting(this);
}

void FIDataCenter::reqOMOSaveSetting()
{
	m_dataOMO.saveSetting(this);
}

void FIDataCenter::reqCNEX()
{
    m_dataCNEX.reqData(this);
}

void FIDataCenter::onDataArrived(const qb::SSAckMsg& msg)
{
    int iRet = 0;
	if (m_dataCIBRepo.onReceive(msg.m_FuncID, msg))
		emit recvCIBRepo();
	else if (m_dataExchRepo.onReceive(msg.m_FuncID, msg))
		emit recvExchRepo();
	else if (m_dataIRS.onReceive(msg.m_FuncID, msg))
		emit recvIRS();
	else if (m_dataShibor.onReceive(msg.m_FuncID, msg))
		emit recvShibor();
	else if (m_dataRepoFixing.onReceive(msg.m_FuncID, msg))
		emit recvRepoFixing();
	else if (m_dataCIBRepoFixing.onReceive(msg.m_FuncID, msg))
		emit recvCIBRepoFixing();
	else if (m_dataOMO.onReceive(msg.m_FuncID, msg))
		emit recvPublicOptionReq();
    else if ( (iRet = m_dataGMktIndex.onReceive(msg.m_FuncID, msg)) >= 0)
        emit recvGMktIndex(iRet, false);
    else if (m_dataCNEX.onReceive(msg.m_FuncID, msg))
        emit recvCNEX();
}
